{set:$average_point=$this->comment_info['average_point'];}
{set:$goods_id=$this->comment['goods_id'];}
{set:$id=intval(IReq::get('id'));}
{set:$item=Api::run('getGoodsInfo',$goods_id)}
<section>
    <div class="pending-detial">
    	<h2>评论商品</h2>
    	{if:$this->can_submit === true}
    	<ul class='block-row'>
        	<li>
	            <p class="head">商品名称：</p>
	            <p class="sum"><a class="orange" href="{url:/site/products/id/$goods_id}">{$item['name']}</a></p>
	        </li>

        	<li>
	            <p class="head">评论等级：</p>
	            <p class="sum">
					<label><input name="point" class="radio" type="radio" value="5" checked="checked" /><span class="grade"><i style="width:{echo:Common::gradeWidth(5)}px"></i></span></label>
					<label><input name="point" class="radio" type="radio" value="4" /><span class="grade"><i style="width:{echo:Common::gradeWidth(4)}px"></i></span></label>
					<label><input name="point" class="radio" type="radio" value="3" /><span class="grade"><i style="width:{echo:Common::gradeWidth(3)}px"></i></span></label>
					<label><input name="point" class="radio" type="radio" value="2" /><span class="grade"><i style="width:{echo:Common::gradeWidth(2)}px"></i></span></label>
					<label><input name="point" class="radio" type="radio" value="1" /><span class="grade"><i style="width:{echo:Common::gradeWidth(1)}px"></i></span></label>
	            </p>
	        </li>

        	<li>
	            <p class="head">评论内容：</p>
	            <p class="sum"><textarea name="contents" id="contents"></textarea></p>
	        </li>

	        <li>
				<p class="head">&nbsp;</p>
				<p class="sum"><input type="button" class="btn" value="保存" onclick="comment_add();" /></p>
	        </li>
    	</ul>
    	{else:}

    	<ul class='block-row'>
			<li><strong>您暂不能对该商品进行评价，可能有以下原因：</strong></li>
			<li>1.您可能没有在{echo:$siteConfig->name}购买过该商品；</li>
			<li>2.您已经评价过该商品。</li>
		</ul>
    	{/if}
    </div>
</section>

<script language="javascript">
function comment_add()
{
	var point=$("input[name='point']:checked").val();
	if(point==0)
	{
		alert("请选择评论等级");
		return;
	}

	var contents=$("#contents").val();
	var data={'point':point,'contents':contents,'id':{$id}};
	$.post("{url:/site/comment_add/id/$id}",data,function(c)
	{
		if(c==='success')
		{
			location="{url:/site/comments_list/id/$goods_id}";
		}
		else
			alert(c);
	});
}
</script>
